import Common from '../../common/common.js';
import FriendList from './FriendList.js';
import {AddFriendWin} from './FriendWin.js';

const doms = {
    addFriend: Common.tool.getElementByID("addFriend"),
    friendList:Common.tool.getElementByID("friendList")
}

const friendList = new FriendList();


const initData = function()
{
    friendList.initData()
}

doms.friendList.appendChild(friendList.getElement());

//绑定添加按钮
Common.tool.addHandle(doms.addFriend,"click",()=>{
    new AddFriendWin().create();
});

//判断用户是否是好友
const isFriend = function(userID){
   let item = friendList.getItems().filter(v=>v.data.userID == userID);
   return item.length > 0;
}

const clear = function(){
    friendList.clearItems();
}

export default {
    initData:initData,
    isFriend:isFriend,
    clear:clear
};
